package org.gwu.seuss.communication.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public abstract class BaseValidator {

	private Pattern pattern;
	private Matcher matcher;
	
	public BaseValidator() {
		pattern = Pattern.compile(getPattern());
	}
	
	/**
	 * Validate password with regular expression
	 * 
	 * @param value for validation
	 * @return true valid value, false invalid value
	 */
	public boolean validate(String value){
		matcher = pattern.matcher(value);
		return (matcher.matches() && extraValidation(value));
	}
	
	
	protected abstract String getPattern();
	
	protected abstract boolean extraValidation(String value);
	
}
